package org.phalanx.client.UI.swing;

import javax.swing.ImageIcon;

import org.phalanx.client.UI.PhalanxIconButton;

public class PhalanxButtonFactory {
	public static final int DEFAULT_OK_BUTTON = 0;
	public static final int DEFAULT_CANCEL_BUTTON = 1;
	public static final int DEFAULT_OPEN_FILE_BUTTON = 2;
	public static final int NAV_MAIN_MENU_BUTTON = 10;
	
	public static final PhalanxIconButton getButton(int buttontype) {
		PhalanxIconButton requestedButton = new PhalanxIconButton();
		
		if (buttontype == DEFAULT_OK_BUTTON) {
			requestedButton = getOkButton();
		}
		else if (buttontype == DEFAULT_CANCEL_BUTTON) {
			requestedButton = getCancelButton();
		}
		else if (buttontype == DEFAULT_OPEN_FILE_BUTTON) {
			requestedButton = getOpenFileButton();
		}
		else if (buttontype == NAV_MAIN_MENU_BUTTON){
			requestedButton = getMainMenuButton();
		}
		
		return requestedButton;
	}
	
	private static final PhalanxIconButton getOkButton() {
		PhalanxIconButton okButton = new PhalanxIconButton();
		okButton.setDefaultIcon(new ImageIcon("./resources/images/buttons/ok.png"));
		okButton.setHoveredIcon(okButton.getIcon(PhalanxIconButton.DEFAULT_ICON));
		okButton.setClickedIcon(new ImageIcon("./resources/images/buttons/okpressed.png"));

		return okButton;
	}
	
	private static final PhalanxIconButton getCancelButton() {
		PhalanxIconButton cancelButton = new PhalanxIconButton();
		cancelButton.setDefaultIcon(new ImageIcon("./resources/images/buttons/cancel.png"));
		cancelButton.setHoveredIcon(cancelButton.getIcon(PhalanxIconButton.DEFAULT_ICON));
		cancelButton.setClickedIcon(new ImageIcon("./resources/images/buttons/cancelpressed.png"));
		
		return cancelButton;
	}
	
	private static final PhalanxIconButton getOpenFileButton() {
		PhalanxIconButton openFile = new PhalanxIconButton();
		openFile.setDefaultIcon(new ImageIcon("./resources/images/buttons/openfile.png"));
		openFile.setHoveredIcon(openFile.getIcon(PhalanxIconButton.DEFAULT_ICON));
		openFile.setClickedIcon(new ImageIcon("./resources/images/buttons/openfilepressed.png"));
		
		return openFile;
	}
	
	private static final PhalanxIconButton getMainMenuButton(){
		PhalanxIconButton mainMenu = new PhalanxIconButton();
		mainMenu.setDefaultIcon(new ImageIcon("./resources/images/buttons/mainmenunav.png"));
		mainMenu.setHoveredIcon(mainMenu.getIcon(PhalanxIconButton.DEFAULT_ICON));
		mainMenu.setClickedIcon(new ImageIcon("./resources/images/buttons/mainmenunavpressed.png"));
		
		return mainMenu;
	}
}
